import {Service, action} from "adajs";
import CommentList from "./../../../controls/lists/comment";

class NewsService extends Service {
    defaultData() {
        return {
            title: "",
            id: "",
            list: {
                url: "/api/admin/cms/cmsComment/query",
                type: CommentList,
                parameter: {
                    siteid: "cyjlgb",
                    articleid: "",
                    t: new Date()
                }
            },
            btns: [
                {action: "listen", icon: ":for-hearing"},
                {action: "add", icon: ":for-add"}
            ]
        };
    }

    onupdate(current, data) {
        Object.assign(current, data);
    }

    @action("load")
    load(current, id) {
        current.id = id;
        current.list.parameter.articleid = id;
    }

    @action("refresh")
    refresh(current) {
        current.list.parameter.t = new Date();
    }
}

export default NewsService;